{% include 'head.html' %}

<!--<script src="{{ url_for('static', filename='js/yzs_index.js') }}" rel="stylesheet"></script>-->


<body>
	<!-- 最为层容器 -->
	<div class="jd_container">
		<!-- 顶部 -->
		<div class="jd_header" style="height: 80px;background-color: #E3EDCD;">

			
			
			<div style="float: left;width: 100%;text-align: center;margin-top: 8px;height: 40%;">
				<a href="/cxpg">
					<img src="static/images/home_cx.png" style="width: 75%;height: 30px;float: left;margin-left: 5%;">
				</a>
				<div style="float: left;width: 10%;margin-top: 2px;margin-left: 5%;">
				<a href="#" id="J_Address"><span style="font-size: 24px;color: #000;width: 10%;"><i class="fa fa-envelope-square"></i></span></a>
			</div>
			</div>
			
			<div style="width: 100%;height: 35px;background-color: #fff;float: left;padding-left: -5%;margin-top: 5px;">
				
				{% if tj %}
					<a href="/">
						<div style="width: 20%;border-bottom:1px solid #BEBEBE;float: left;text-align: center;background-color: #fff;height: 30px;"> 
							<h4 style="margin-top: 2px;color: red;margin-bottom: -2px;">推荐</h4>  
							<i class="fa fa-minus" style="color: red;"></i><i class="fa fa-minus" style="color: red;"></i>
						</div>
					</a>
				{% else %}
					<a href="/">
						<div style="width: 20%;border-bottom:1px solid #BEBEBE;float: left;text-align: center;background-color: #fff;height: 30px;"> 
							<h4 style="margin-top: 5px;color: #6C6C6C;">推荐</h4>  
						</div>
					</a>
				{% endif %}

				
				{% if hot %}
					<a href="/typewz?type=hot" '>
						<div style="width: 20%;border-bottom:1px solid #BEBEBE;float: left;text-align: center;background-color: #fff;height: 30px;"> 
							<h4 style="margin-top: 2px;color: red;margin-bottom: -2px;">最火</h4> 
							<i class="fa fa-minus" style="color: red;"></i><i class="fa fa-minus" style="color: red;"></i>
						</div>
					</a>
				{% else %}
					<a href="/typewz?type=hot" '>
						<div style="width: 20%;border-bottom:1px solid #BEBEBE;float: left;text-align: center;background-color: #fff;height: 30px;"> 
							<h4 style="margin-top: 5px;color: #6C6C6C;">最火</h4> 
						</div>
					</a>
				{% endif %}


				{% if new %}
					<a href="/typewz?type=new">
						<div style="width: 20%;border-bottom:1px solid #BEBEBE;float: left;text-align: center;background-color: #fff;height: 30px;"> 
							<h4 style="margin-top: 2px;color: red;margin-bottom: -2px;">最新</h4> 
							<i class="fa fa-minus" style="color: red;"></i><i class="fa fa-minus" style="color: red;"></i>
						</div>
					</a>
				{% else %}
					<a href="/typewz?type=new">
						<div style="width: 20%;border-bottom:1px solid #BEBEBE;float: left;text-align: center;background-color: #fff;height: 30px;"> 
							<h4 style="margin-top: 5px;color: #6C6C6C;">最新</h4> 
						</div>
					</a>
				{% endif %}


				{% if plhot %}
					<a href="/typewz?type=plhot">
						<div style="width: 20%;border-bottom:1px solid #BEBEBE;float: left;text-align: center;background-color: #fff;height: 30px;"> 
							<h4 style="margin-top: 2px;color: red;margin-bottom: -2px;">热评</h4>
							<i class="fa fa-minus" style="color: red;"></i><i class="fa fa-minus" style="color: red;"></i>
						</div>
					</a>
				{% else %}
					<a href="/typewz?type=plhot">
						<div style="width: 20%;border-bottom:1px solid #BEBEBE;float: left;text-align: center;background-color: #fff;height: 30px;"> 
							<h4 style="margin-top: 5px;color: #6C6C6C;">热评</h4>
						</div>
					</a>
				{% endif %}

				<a href="/cxpg">
					<div style="width: 20%;border-bottom:1px solid #BEBEBE;float: left;text-align: center;background-color: #fff;height: 30px;"> 
						<h4 style="margin-top: 5px;color: #6C6C6C;">全部</h4> 
					</div>
				</a>

			</div>
		</div>
		


</div>




		
		<div style="width: 100%;height: 50px;">
			
		</div>
		





		<!-- 导航栏 -->
		<div class="jd_nav" style="background-color: #fff;margin-top: 10px;">

		</div>

		{% for wzdata in wzlist %}

			{% if wzdata["show1"] %}
				<div style="width: 100%;padding-left: 5%;padding-top: 5%;margin-bottom: 20px;">
					<a href="/read?type={{ wzdata['type'] }}&id={{ wzdata['id'] }}">
						<div style="width: 95%;"><span style="font-size: 24px;color: #000;"><b>{{ wzdata["title"] }}</b></span></div>
						<div style="color: #6C6C6C;margin-top: 5px;">
							<span class="label label-info">{{ wzdata["fenlei"] }}</span><span style="margin-left: 10px;">
								<i class="fa fa-eye"></i> {{ wzdata["ck"] }}
							</span>
							<span style="margin-left: 10px;">评论:{{ wzdata["pl"] }}</span>
							<span style="margin-left: 10px;">{{ wzdata["date"] }}</span>
						</div>
					</a>
				</div>
				<div style="width: 100%;height: 5px;background-color: #e7e8e8;margin-top: 10px;"></div>
			{% endif %}

			{% if wzdata["showimg"] %}

				{% if wzdata["img_len"] == 1 %}
					<div style="width: 100%;padding-left: 5%;padding-top: 5%;margin-bottom: 20px;">
						<a href="/read?type={{ wzdata['type'] }}&id={{ wzdata['id'] }}">
							<div style="width: 100%;height: 80px;">
								{% for imges in wzdata["imgs"] %}
									<img class="img-rounded" src="http://hbsj.qiye6666.com{{ imges }}" style="width: 30%;height: 80px;float: left;">
								{% endfor %}
								<span class="show1span" style="font-size: 24px;width: 65%;height: 80px;float: right;margin-right: 3%;min-height: 0px;margin-left: 0px;"><b style="padding-right: 5%;color: #000;">{{ wzdata["title"] }}</b></span>
							</div>
							<div style="color: #6C6C6C;margin-top: 5px;margin-top: 10px;width: 100%;">
								<span class="label label-info">{{ wzdata["fenlei"] }}</span><span style="margin-left: 10px;">
									<i class="fa fa-eye"></i> {{ wzdata["ck"] }}
								</span>
								<span style="margin-left: 10px;">评论:{{ wzdata["pl"] }}</span>
								<span style="margin-left: 10px;">{{ wzdata["date"] }}</span>
							</div>
						</a>
					</div>
					<div style="width: 100%;height: 5px;background-color: #e7e8e8;margin-top: 10px;"></div>

				{% else %}
					<div style="width: 100%;padding-left: 5%;padding-top: 5%;margin-bottom: 30px;">
						<a href="/read?type={{ wzdata['type'] }}&id={{ wzdata['id'] }}">
							<div style="width: 100%;padding-bottom: 10px;padding-right: 10px;">
								<span style="font-size: 24px;margin-left: 10px;margin-right: 10px;color: #000;"><b>{{ wzdata["title"] }}</b></span>
							</div>
							{% for imges in wzdata["imgs"] %}
								<img class="img-rounded" src="http://hbsj.qiye6666.com{{ imges }}" style="width: 30%;height: 68px;">
							{% endfor %}
							
							<div style="color: #6C6C6C;margin-top: 5px;margin-top: 10px;">
								<span class="label label-info">{{ wzdata["fenlei"] }}</span><span style="margin-left: 10px;">
									<i class="fa fa-eye"></i> {{ wzdata["ck"] }}
								</span>
								<span style="margin-left: 10px;">评论:{{ wzdata["pl"] }}</span>
								<span style="margin-left: 10px;">{{ wzdata["date"] }}</span>
							</div>
						</a>
					</div>
					<div style="width: 100%;height: 5px;background-color: #e7e8e8;margin-top: 10px;"></div>

				{% endif %}

			{% endif %}

			
		{% endfor %}

		

		


		<div id="more"></div>


		<!-- 京东内容区域 -->
		<div class="jd_mian">
			<div class="main_content" style="background-color: #E7e8e8;margin-bottom: 100px;">
	
				</div>
					
				</div>
				
			</div>
		</div>
	</div>



{% include 'js.html' %}

<script type="text/javascript">

//获取滚动条当前的位置
function getScrollTop() {
    var scrollTop = 0;
    if(document.documentElement && document.documentElement.scrollTop) {
        scrollTop = document.documentElement.scrollTop;
    } else if(document.body) {
        scrollTop = document.body.scrollTop;
    }
    return scrollTop;
}


//获取当前可视范围的高度  
function getClientHeight() {
    var clientHeight = 0;
    if(document.body.clientHeight && document.documentElement.clientHeight) {
        clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);
    } else {
        clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight);
    }
    return clientHeight;
}


//获取文档完整的高度 
function getScrollHeight() {
    return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
}




	$('.show1span b').each(function() {
        var words = $(this).text().length;
        if(words > 15){
            $(this).text($(this).text().slice(0,15)+"...");
        }
    });




//获取当前url的path函数
function GetUrlRelativePath()
　　{
　　　　var url = document.location.toString();
　　　　var arrUrl = url.split("//");
　　　　var start = arrUrl[1].indexOf("/");
　　　　var relUrl = arrUrl[1].substring(start);//stop省略，截取从start开始到结尾的所有字符
　　　　if(relUrl.indexOf("?") != -1){
　　　　　　relUrl = relUrl.split("?")[0];
　　　　}
　　　　return relUrl;
　}



function codtemp(type_val, id_val, title_val, fenlei_val, ck_val, pl_val, date_val){
	var cod_temps = '<div style="width: 100%;padding-left: 5%;padding-top: 5%;margin-bottom: 20px;">\
					<a href="/read?type='+type_val+'&id='+id_val+'">\
						<div style="width: 95%;"><span style="font-size: 24px;color: #000;"><b>'+title_val+'</b></span></div>\
						<div style="color: #6C6C6C;margin-top: 5px;">\
							<span class="label label-info">'+fenlei_val+'</span><span style="margin-left: 10px;">\
								<i class="fa fa-eye"></i>'+ck_val+'\
							</span>\
							<span style="margin-left: 10px;">评论:'+pl_val+'</span>\
							<span style="margin-left: 10px;">'+date_val+'</span>\
						</div>\
					</a>\
				</div>\
				<div style="width: 100%;height: 5px;background-color: #e7e8e8;margin-top: 10px;"></div>';
	return  cod_temps;
}



function codtemp_img(type_val, id_val, imgs_list, title_val, fenlei_val, ck_val, pl_val, date_val){
	var cod_temps = '<div style="width: 100%;padding-left: 5%;padding-top: 5%;margin-bottom: 20px;">\
						<a href="/read?type='+type_val+'&id='+id_val+'">\
							<div style="width: 100%;height: 80px;">\
									<img class="img-rounded" src="http://hbsj.qiye6666.com'+imgs_list[0]+'" style="width: 30%;height: 80px;float: left;">\
								<span class="show1span" style="font-size: 24px;width: 65%;height: 80px;float: right;margin-right: 3%;min-height: 0px;margin-left: 0px;"><b style="padding-right: 5%;color: #000;">'+title_val+'</b></span>\
							</div>\
							<div style="color: #6C6C6C;margin-top: 5px;margin-top: 10px;width: 100%;">\
								<span class="label label-info">'+fenlei_val+'</span><span style="margin-left: 10px;">\
									<i class="fa fa-eye"></i> '+ck_val+'\
								</span>\
								<span style="margin-left: 10px;">评论:'+pl_val+'</span>\
								<span style="margin-left: 10px;">'+date_val+'</span>\
							</div>\
						</a>\
					</div>\
					<div style="width: 100%;height: 5px;background-color: #e7e8e8;margin-top: 10px;"></div>';
	return  cod_temps;
}


function codtemp_img3(type_val, id_val, imgs_list, title_val, fenlei_val, ck_val, pl_val, date_val){
	var imges_show = ""
	for (imgnum in imgs_list) {
		imges_show+= '<img class="img-rounded" src="http://hbsj.qiye6666.com'+imgs_list[imgnum]+'" style="width: 30%;height: 68px;margin-left:2%;">'
	}
	var cod_temps = '<div style="width: 100%;padding-left: 5%;padding-top: 5%;margin-bottom: 30px;">\
						<a href="/read?type='+type_val+'&id='+id_val+'">\
							<div style="width: 100%;padding-bottom: 10px;padding-right: 10px;">\
								<span style="font-size: 24px;margin-left: 10px;margin-right: 10px;color: #000;"><b>'+title_val+'</b></span>\
							</div>\
							'+imges_show+'\
							<div style="color: #6C6C6C;margin-top: 5px;margin-top: 10px;">\
								<span class="label label-info">'+fenlei_val+'</span><span style="margin-left: 10px;">\
									<i class="fa fa-eye"></i> '+ck_val+'\
								</span>\
								<span style="margin-left: 10px;">评论:'+pl_val+'</span>\
								<span style="margin-left: 10px;">'+date_val+'</span>\
							</div>\
						</a>\
					</div>\
					<div style="width: 100%;height: 5px;background-color: #e7e8e8;margin-top: 10px;"></div>';
	return  cod_temps;
}


function show_cod(datas){
	var jsondatas = JSON.parse(datas);
    //console.log(jsondatas);
    //alert(typeof(jsondatas));
    for(datasinfo in jsondatas){
      //console.log(jsondatas[datasinfo]);
      var infos = jsondatas[datasinfo];
      /*
      console.log(infos);
      console.log(infos["show1"]);
      console.log(infos["id"]);
      console.log(infos["title"]);
      console.log(infos["fenlei"]); 
      console.log(infos["date"]); 
      console.log(infos["pl"]); 
      console.log(infos["ck"]); 
      console.log(infos["type"]); 
	  */

      if(infos["show1"]){
      	$("#more").append(codtemp(infos["type"], infos["id"], infos["title"], infos["fenlei"], infos["ck"], infos["pl"], infos["date"]
                                ));
      }
      else if(infos["showimg"]){
      	if(infos["imgs"].length == 1){
      		console.log("11111111111111111111111111111"); 
      		$("#more").append(codtemp_img(infos["type"], infos["id"], infos["imgs"], infos["title"], infos["fenlei"], infos["ck"], infos["pl"], infos["date"]
                                ));
      	}
      	else{
      		$("#more").append(codtemp_img3(infos["type"], infos["id"], infos["imgs"], infos["title"], infos["fenlei"], infos["ck"], infos["pl"], infos["date"]
                                ));
      	}
      	
      }
      

    }
}




//请求
//下拉接口判断
//判断是需要调用哪个接口
function next_cod(pgnum){
    //获取当前url 的 path
    var now_url = GetUrlRelativePath();
    //alert(now_url);
    var urls = ""

    

      if(now_url == "/"){
        urls = "nextwz?gettype=tj&numb="+pgnum;
        console.log(urls);
      	}
      else if(now_url == "/typewz"){
        urls = "nextwz?gettype={{ gettype }}&numb="+pgnum;
        console.log(urls);
      	}
      else if(now_url == "/search"){
        urls = "nextwz?gettype=search&keys={{ keyd }}&numb="+pgnum;
        console.log(urls);
      	}
      else if(now_url == "/fenleisearch"){
        urls = "nextwz?gettype=fenleisearch&keys={{ keyd }}&numb="+pgnum;
        console.log(urls);
      	}
      else{
        urls = "nextwz?gettype=tj&numb="+pgnum;
        console.log(urls);
      	}

      console.log(urls);
      get_api_ajax2(urls,show_cod);
  
}





  var qnumber = 0;

  //var newkey = "{{keys}}";

  $(window).scroll(function () {
   

    console.log(getScrollTop());
    console.log(getClientHeight());
    console.log(getScrollHeight());
      if(getScrollTop() + getClientHeight() >= getScrollHeight()) {
          console.log('下拉刷新了');
          //此处发起AJAX请求
          //alert("下拉刷新了");
          qnumber+=1;

          webToast('文章加载中...','middle',2000);
          next_cod(qnumber);
      }


  }).trigger("scroll");

</script>


{% include 'foot.html' %}

